//
//  memberOfuinquePtr.hpp
//  learnC++
//
//  Created by liuzhibing on 2018/6/30.
//  Copyright © 2018年 yunfan.com. All rights reserved.
//

#ifndef memberOfuinquePtr_hpp
#define memberOfuinquePtr_hpp

#include <stdio.h>
#include <memory>
#include <iostream>
using namespace std;

class Dog {
private:
    int m_age;
public:
    Dog(int age = 0):m_age(age){
        cout << "Dog init";
    }
    ~Dog(){
        cout << "Dog dealloc\n";
    }
};

class People {
private:
    
    int m_age;
    std::unique_ptr<Dog> m_dog;
    
public:
    
    People(std::unique_ptr<Dog> dog,int age):m_dog(std::move(dog)),m_age(age){
        cout << "People init\n";
    }
    
    ~People(){
        cout << "People dealloc";
    }
    
};

/*
 
 auto dog = std::make_unique<Dog>(1);
 
 People p(std::move(dog),12);
 
 */

#endif /* memberOfuinquePtr_hpp */
